<template>
    <div id="tmpl">
        <div class="back">
            <span @click="goback">< 返回</span>
            <span>图文咨询</span>
        </div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList">
                <router-link v-bind="{to:'/news/newsshow/' + item.id}">
                    <img :src="item.img_url" class="mui-media-object mui-pull-left">
                    <div class="mui-media-body">
                        <h5 class="mui-ellipsis">{{item.title}}</h5> 
                        <p class='mui-ellipsis'>
                            <span>发表时间：{{ item.add_time | datefmt("YYYY-MM-DD") }}</span>
                            <span>点击：{{item.click}}</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

 <script type="text/ecmascript-6">
import common from '../../api/common.js'
export default {
    data() {
        return {
            newsList: []
        }
    },
    created() {
        this.getNewsList()
    },
    methods: {
        getNewsList() {
            var url = common.apidomain + '/api/getnewslist'
            this.$http.get(url).then(function (res) {
                var data = res.body
                if (data.status != 0) {
                    Toast(data.message)
                    return
                }
                this.newsList = data.message
            })
        },
        formartTime(time) {
            return time.split('T')[0]
        },
        goback() {
            this.$router.go(-1)
        }
    }
}
</script>

<style scoped>
.back {
    height: 40px;
    background: #F5F5F5;
    line-height: 40px;
    position: relative;
    color: #0277BD;
}
.back span:first-of-type {
    float: left;
    margin-left: 10px;
}  
.back span:last-of-type {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}  
.mui-media-body {
    word-wrap: break-word;
}
.mui-media-body p {
    color: #40C4FF;
}
.mui-media-body p span:last-of-type {
    float: right;
}
</style>